package com.bhs.sansonglogistics.ui.mine;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.widget.CompoundButton;
import android.widget.Switch;
import android.widget.TextView;

import com.bhs.sansonglogistics.R;
import com.bhs.sansonglogistics.base.BaseActivity;
import com.bhs.sansonglogistics.utils.SharedPreferencesUtils;

/**
 * 消息设置
 */
public class MessageSetActivity extends BaseActivity {

    private Switch mSwChatHint;
    private Switch mSwSystemPush;
    private Switch mSwActivityPush;

    @Override
    public int initLayout() {
        return R.layout.activity_message_set;
    }

    @Override
    public void initView() {

        TextView mTvTitle = findViewById(R.id.tv_title);
        mTvTitle.setText("消息设置");
        mSwChatHint = findViewById(R.id.sw_chat_hint);
        mSwSystemPush = findViewById(R.id.sw_system_push);
        mSwActivityPush = findViewById(R.id.sw_activity_push);
    }

    @Override
    public void initData() {
        boolean chatHint= SharedPreferencesUtils.getBoolean(mActivity,"chatHint",false);
        boolean systemPush= SharedPreferencesUtils.getBoolean(mActivity,"systemPush",false);
        boolean activityPush= SharedPreferencesUtils.getBoolean(mActivity,"activityPush",false);
        mSwActivityPush.setChecked(activityPush);
        mSwChatHint.setChecked(chatHint);
        mSwSystemPush.setChecked(systemPush);
        mSwActivityPush.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
                SharedPreferencesUtils.saveBoolean(mActivity,"activityPush",b);
            }
        });
        mSwChatHint.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
                SharedPreferencesUtils.saveBoolean(mActivity,"chatHint",b);
            }
        });
        mSwSystemPush.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
                SharedPreferencesUtils.saveBoolean(mActivity,"systemPush",b);
            }
        });
    }
}